package com.lanou.service;

import com.lanou.bean.Cost;
import com.lanou.mapper.CostMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by lanouhn on 17/10/21.
 */
@Service("costservice")
public class CostServiceImpl implements CostService{

    @Autowired
    private CostMapper costMapper;

    @Override
    public List<Cost> selectAllCostInfo() {
        return costMapper.selectAllCostInfo();
    }

    @Override
    public int insertCost(String name,String base_duration,String base_cost,String unit_cost,String descr) {
        return costMapper.insertCost(name,base_duration,base_cost,unit_cost,descr);
    }

    @Override
    public int deleteCostById(Integer cost_id) {
        return costMapper.deleteCostById(cost_id);
    }

    @Override
    public int deleteserviceById(Integer cost_id) {
        return costMapper.deleteserviceById(cost_id);
    }

    @Override
    public List<Cost> selectAllCostAndSort() {
        return costMapper.selectAllCostAndSort();
    }

    @Override
    public List<Cost> selectAllCostAndSortByCost() {
        return costMapper.selectAllCostAndSortByCost();
    }

    @Override
    public Cost selectByPrimaryKey(Integer cost_id) {
        return costMapper.selectByPrimaryKey(cost_id);
    }

    @Override
    public int updateCost(@Param("cost_id") Integer cost_id, @Param("name") String name, @Param("base_duration") String base_duration, @Param("base_cost") String base_cost, @Param("unit_cost") String unit_cost, @Param("descr") String descr) {
        return costMapper.updateCost(cost_id,name,base_duration,base_cost,unit_cost,descr);
    }

    @Override
    public int updateCostStatus(@Param("cost_id") Integer cost_id, @Param("status") Integer status, @Param("startime") String startime) {
        return costMapper.updateCostStatus(cost_id,status,startime);
    }

    @Override
    public Cost selectCostByName(Integer cost_id) {
        return costMapper.selectCostByName(cost_id);
    }
}
